void main() {
  // 准备购物车数据
  List carts = [
    {"count": 2, "price": 10.0, "selected": true},
    {"count": 1, "price": 30.0, "selected": false},
    {"count": 5, "price": 20.0, "selected": true}
  ];
  // print('原始数据：$carts');
  double totalPrice = 0;
  carts.forEach((item) {
    if (item['selected']) {
      totalPrice += item['price'] * item['count'];
    }
  });
  print('总价格：${totalPrice}');

  double total = 0;
  for (var i = 0; i < carts.length; i++) {
    if (carts[i]['selected']) {
      total += carts[i]['price'] * carts[i]['count'];
    }
  }
  print('总价格为：$total');
}
